import {
  AUTO_LOGIN_URL,
  APP_VALIDATE_URL,
  APP_LOGIN_URL,
  APP_ROLELIST_URL,
  APP_USERINFO_URL,
  UPDATE_USERINFO_URL,
  PIC_APP
} from "@/config/url.conf";
import {ajax} from "@/utils/request";
/**
 * 自动登录
 * @param {*} token
 * @returns
 */
export const autoLoginApi = (token) => {
  return ajax({
    method: "post",
    url: AUTO_LOGIN_URL,
    data: { token },
  });
};

/**
 * 获取验证码
 * @param {*} phone
 * @returns
 */
 export const validateApi = (phone) => {
  return ajax({
    url: APP_VALIDATE_URL,
    method: "post",
    data: { phone },
  });
};

/**
 * 获取角色信息
 * @returns
 */
export const userRoleApi = (ids) => {
  return ajax({
    url: APP_ROLELIST_URL,
    params:{ids}
  });
};


/**
 * app登录
 * @param {{phone:number,vdtCode:string}} data
 * @returns
 */
export const loginApi = (data) => {

  return ajax({
    method: "post",
    url: APP_LOGIN_URL,
    data,
  });
};
/**
 * 获取单个用户信息
 * @param {String} id
 * @returns
 */
export const userInfoApi = (id) => {
  return ajax({
    url: APP_USERINFO_URL,
    params: { id },
  });
};

/**
 * 修改用户信息
 * @param {*} data 
 * @returns 
 */
export const userUpdateApi = (data) =>{
  return ajax({
    url:UPDATE_USERINFO_URL,
    method:'post',
    data
  })
}

/**
 * 上传文件流头像
 * @param {*} file 
 * @returns 
 */
export const getPicApi = (fileName) => {
  return ajax({
    method:'post',
    url: PIC_APP,
    data:fileName ,
  });
};